package com.syg.validation.controller;

import com.syg.validation.domain.User;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author syg
 */
@RestController
public class ValidationController {

    @PostMapping("/save")
    public String saveUser(@RequestBody @Validated(User.Save.class) User user) {
        // 校验通过，才会执行业务逻辑处理
        return "成功";
    }

    @PostMapping("/update")
    public String updateUser(@RequestBody @Validated(User.Update.class) User user) {
        // 校验通过，才会执行业务逻辑处理
        return "成功";
    }
}
